-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datacube: enable saving and loading local file source in DataCube grid #3903
base: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: e2aedd6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
import { DataCubeSource } from './DataCubeSource.js'; | ||
import type { PlainObject } from '@finos/legend-shared'; | ||
|
||
export class CachedDataCubeSource extends DataCubeSource { | ||
model!: PlainObject<V1_PureModelContextData>; | ||
model!: PlainObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change? It's not useful type-checking wise, but it's a coding guide
@@ -31,7 +30,7 @@ export enum LocalFileDataCubeSourceFormat { | |||
} | |||
|
|||
export class LocalFileDataCubeSource extends DataCubeSource { | |||
model!: PlainObject<V1_PureModelContextData>; | |||
model!: PlainObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, revert this
@@ -31,7 +31,7 @@ export const LocalFileDataCubeSourceBuilder = observer( | |||
text={`Currently, support for local file comes with the following limitations: | |||
- Only CSV files are supported, but not all variants of CSV files are supported (required header row, comma delimiter, single escape quote). | |||
- Data from uploaded file will not be stored nor shared. | |||
- DataCube created with local file source cannot be saved.`} | |||
- DataCube from uploaded file can be stored but when loading this, you will have to reupload source data.`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this line.
import type { LegendDataCubeApplicationStore } from '../../../LegendDataCubeBaseStore.js'; | ||
import type { LegendDataCubeDataCubeEngine } from '../../../LegendDataCubeDataCubeEngine.js'; | ||
|
||
export abstract class LegendDataCubeSourceLoaderBuilderState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this and the file to LegendDataCubeSourceLoaderState
} from '../../../model/LocalFileDataCubeSource.js'; | ||
import { LegendDataCubeSourceLoaderBuilderState } from './LegendDataCubeSourceLoaderBuilderState.js'; | ||
|
||
export class LocalFileDataCubeSourceLoaderBuilderState extends LegendDataCubeSourceLoaderBuilderState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalFileDataCubeSourceLoaderBuilderState
-> LocalFileDataCubeSourceLoaderState
return false; | ||
} | ||
|
||
changeSourceBuilder(type: string): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mindful and scan everywhere you copy code, change builder
to loader
changeSourceBuilder(type: string): void { | |
changeSourceLoader(type: string): void { |
|
||
abstract generateSourceData(): Promise<PlainObject>; | ||
|
||
abstract validateSourceData(source: PlainObject | undefined): boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as commented in LocalFile...SourceLoader
, the spirit is wrong here, we don't need this method
|
||
abstract get isValid(): boolean; | ||
|
||
abstract generateSourceData(): Promise<PlainObject>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying the code from sourcebuilder
is not 100% appropriate here, we are NOT trying to generate
new source, we're trying to loadSource
, this method should be changed to
abstract generateSourceData(): Promise<PlainObject>; | |
abstract load(sourceData: PlainObject): Promise<PlainObject>; |
@@ -295,6 +299,27 @@ export class LegendDataCubeBuilderStore { | |||
const specification = DataCubeSpecification.serialization.fromJson( | |||
persistentDataCube.content, | |||
); | |||
|
|||
if ( | |||
!this.saveState.hasSucceeded && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we use saveState
here??
this.sourceLoader.changeSourceBuilder( | ||
specification.source._type as string, | ||
); | ||
this.sourceLoader.setSource(specification.source); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of UX and componentization, I think this is not accurate. What we want is not yet another window on top of the current window for people to pick the source, this is more the second stage of the wizard to load query. We have to follow the following flow:
(1) When people load /datacube/:id
: if we spot a partial source, we could redirect to /datacube
and open the loader and fast-forward to the wizard step in the loader where people have to provide the source, we need to do some special trick to not get stuck in a loop (e.g. after loading the partial source, user redirected to /datacube/:id
and hence infinite loop ) <-- need to think what we do here? Or we can leave people on the same page /datacube/:id
and do something.
(2) And the other flow, in loader
, when people just casually working in DataCube and decide to click Load DataCube
, the loader can come up and people can select a DataCube with partial source, that's another flow you have to handle
It's best to think of a strategy to homogenize these 2 flows and just have (1) uses the logic in (2)
Summary
How did you test this change?